Skip to content

lib: add process.loadedModules list - #61330

Open
Xstoudi wants to merge 4 commits into
nodejs:mainfrom
Xstoudi:feat/process-loaded-modules
Open

lib: add process.loadedModules list#61330
Xstoudi wants to merge 4 commits into
nodejs:mainfrom
Xstoudi:feat/process-loaded-modules

Conversation

@Xstoudi

@Xstoudi Xstoudi commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Add a new process.loadedModules property that returns an array of public core module names that have been loaded during the current Node.js process execution. This provides a cleaner, documented API for accessing loaded module information compared to the undocumented process.moduleLoadList.

Fixes: #41233
Refs: #61276

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jan 9, 2026
Add a new `process.loadedModules` property that returns an array
of public core module names that have been loaded during the current
Node.js process execution. This provides a cleaner, documented API
for accessing loaded module information compared to the undocumented
`process.moduleLoadList`.

Fixes: nodejs#41233
Refs: nodejs#61276
@Xstoudi
Xstoudi force-pushed the feat/process-loaded-modules branch from 8530bcb to afe4f56 Compare January 9, 2026 23:18
@codecov

codecov Bot commented Jan 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.67%. Comparing base (842448b) to head (8c978fa).
⚠️ Report is 1777 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61330      +/-   ##
==========================================
+ Coverage   88.00%   89.67%   +1.66%     
==========================================
  Files         704      676      -28     
  Lines      208739   206481    -2258     
  Branches    40196    39536     -660     
==========================================
+ Hits       183706   185161    +1455     
+ Misses      16992    13465    -3527     
+ Partials     8041     7855     -186     
Files with missing lines Coverage Δ
lib/internal/bootstrap/realm.js 96.50% <100.00%> (+2.61%) ⬆️

... and 353 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

require('../common');
const assert = require('assert');

assert.ok(Array.isArray(process.loadedModules));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a little more on what's in that is actually what it should be :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a better now? I'm not willing to test exact values in there to avoid flacky tests, am I wrong?

Comment thread lib/internal/bootstrap/realm.js Outdated
Comment on lines +417 to +419
if (!StringPrototypeStartsWith(id, 'internal/')) {
ArrayPrototypePush(loadedModules, id);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle #61276 (comment) and #61276 (comment) from Joyee had on your previous doc PR?

I think it specifically doesn't handle:

the names of the modules are also highly volatile and cannot be reliably depended on

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have misunderstood Joyee's feedback, but I tought the internal/ prefix to be somehow reliable as it's almost as old as Node.js itself. Can you think of something else? :/

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

@github-actions github-actions Bot added the stale label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. stale test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc: process.moduleLoadList not documented

3 participants